<template>
  <a-card :bordered="false">
    <f-table ref="table"  rowKey="materialPlanId" :scroll="{x:3410,y:500}" :operator="operator"  :columns="newColumns" :multiple="false"  :params="queryParam" :api="api.material" >
    </f-table>
  </a-card>
</template>

<script>
  import api from './js/api'
  import Vue from 'vue'
  export default {
    name: 'TableList',
    components: {
    },
    props: {
      projectId: {
        type: String,
        default: ''
      }
    },
    data() {
      const token = Vue.ls.get('Access-Token')
      let me = this
      return {
        projectIds: {},
        projectStatus: '',
        projectVersion100: '',
        api: Object.assign(api, this.api),
        headers: { 'Authorization': token },
        tableId: 'appUser',
        //列表初始化查询参数
        queryParam: { },
        // 树形缩进
        indentSize: 35,
        newColumns: [],
        // 表头
        columns: [
          {
            title: '专业名称',
            align: 'center',
            dataIndex: 'majorName',
            width: 150
          },
          {
            title: '专业代码',
            align: 'center',
            dataIndex: 'majorCode',
            width: 100

          },
          {
            title: '工程包名称',
            align: 'center',
            dataIndex: 'packageName',
            width: 100
          },
          {
            title: '工程包代码',
            align: 'center',
            dataIndex: 'packageNo',
            width: 100
          },
          {
            title: '材料WBS代码',
            align: 'center',
            dataIndex: 'materialWbsCode',
            width: 100
          },
          {
            title: '全物料代码',
            align: 'center',
            dataIndex: 'materialCode',
            width: 150
          },
          {
            title: '设备、材料名称',
            align: 'center',
            dataIndex: 'materialName',
            width: 150
          },
          // {
          //   title: '型号/规格',
          //   align: 'center',
          //   dataIndex: 'materiaSpecs',
          //   width: 150
          // },
          {
            title: '项目名称',
            align: 'center',
            dataIndex: 'materiaSpecs',
            width: 150
          },
          {
            title: '材料项目描述',
            align: 'center',
            dataIndex: 'materialDesc',
            width: 150
          },
          {
            title: '技术参数或技术说明',
            align: 'center',
            dataIndex: 'technicalData',
            width: 150
          },
          {
            title: '服务WBS代码',
            align: 'center',
            dataIndex: 'serviceWbsCode',
            width: 100
          },
          {
            title: '服务代码',
            align: 'center',
            dataIndex: 'serviceCode',
            width: 100
          },
          {
           title: '科目名称',
            align: 'center',
            dataIndex: 'subjectName',
            width: 100
          },
          {
            title: '分承包发包项目描述',
            align: 'center',
            dataIndex: 'packageDesc',
            width: 150
          },
          {
            title: '层级号',
            align: 'center',
            dataIndex: 'levelNo',
            width: 100
          },
          {
            title: '对外合同清单描述',
            align: 'center',
            dataIndex: 'contractDesc',
            width: 150
          },
          {
            title: '分区域',
            align: 'center',
            dataIndex: 'materialArea',
            width: 150
          },
          {
            title: '分系统',
            align: 'center',
            dataIndex: 'materialUse',
            width: 150
          },
          {
            title: '合同清单工程量',
            align: 'center',
            dataIndex: 'contractBillQuantity',
            width: 150
          },
          {
            title: '标前工程量',
            align: 'center',
            dataIndex: 'beforeMarkQuantity',
            width: 150
          },
          {
            title: '100预算成本工程量',
            align: 'center',
            dataIndex: 'costQuantity100',
            width: 150
          },
          {
            title: '200预算成本工程量',
            align: 'center',
            dataIndex: 'costQuantity200',
            width: 150
          },
          {
            title: '损耗',
            align: 'center',
            dataIndex: 'loss',
            width: 150
          },
          {
            title: '计量单位',
            align: 'center',
            dataIndex: 'measurementUnit',
            width: 150
          },
          {
            title: ' 100采购计划量',
            align: 'center',
            dataIndex: 'planPurchaseCount',
            width: 150
          },
          {
            title: '200采购计划量',
            align: 'center',
            dataIndex: 'planPurchaseCount1',
            width: 150
          },
          {
            title: '完成工程量',
            align: 'center',
            dataIndex: '',
            width: 150,
            children: [
              {
                title: '本月完成工程量',
                align: 'center',
                dataIndex: 'currentFinishMonthCount',
                width: 150
              },
              {
                title: '截止上月完成工程量',
                align: 'center',
                dataIndex: 'lastFinishMonthCount',
                width: 150
              },
              {
                title: '累计完成工程量',
                align: 'center',
                dataIndex: 'totalFinishCount',
                width: 150
              }
            ]
          },
          {
            title: '预算成本单价（未税）',
            align: 'center',
            dataIndex: '',
            width: 150,
            children: [
              {
                title: '单价',
                align: 'center',
                dataIndex: '',
                width: 150,
                children: [
                  {
                    title: '主材价',
                    align: 'center',
                    dataIndex: 'mainPrice',
                    width: 150
                  },
                  {
                    title: '安装价',
                    align: 'center',
                    dataIndex: 'installPrice',
                    width: 150
                  },
                  {
                    title: '综合单价',
                    align: 'center',
                    dataIndex: 'syntheticalPrice',
                    width: 150
                  }
                ]
              },
              {
                title: '合价',
                align: 'center',
                dataIndex: '',
                width: 150,
                children: [
                  {
                    title: '主材费',
                    align: 'center',
                    dataIndex: 'mainAmount',
                    width: 150
                  },
                  {
                    title: '安装费',
                    align: 'center',
                    dataIndex: 'installAmount',
                    width: 150
                  },
                  {
                    title: '合计',
                    align: 'center',
                    dataIndex: 'syntheticalAmount',
                    width: 150
                  }
                ]
              }
            ]
          },
          {
            title: '对外合同单价',
            align: 'center',
            dataIndex: '',
            width: 150,
            children: [
              {
                title: '有合同价（单价）',
                align: 'center',
                dataIndex: '',
                width: 150,
                children: [
                  {
                    title: '主材价',
                    align: 'center',
                    dataIndex: 'mainPrice1',
                    width: 150
                  },
                  {
                    title: '安装价',
                    align: 'center',
                    dataIndex: 'installPrice1',
                    width: 150
                  },
                  {
                    title: '综合单价',
                    align: 'center',
                    dataIndex: 'syntheticalPrice1',
                    width: 150
                  }
                ]
              },
              {
                title: '拟合同价（单价）',
                align: 'center',
                dataIndex: '',
                width: 150,
                children: [
                  {
                    title: '主材价',
                    align: 'center',
                    dataIndex: 'mainPrice2',
                    width: 150
                  },
                  {
                    title: '安装价',
                    align: 'center',
                    dataIndex: 'installPrice2',
                    width: 150
                  },
                  {
                    title: '综合单价',
                    align: 'center',
                    dataIndex: 'syntheticalPrice2',
                    width: 150
                  }
                ]
              },
              {
                title: '合同价（单价）',
                align: 'center',
                dataIndex: '',
                width: 150,
                children: [
                  {
                    title: '主材价',
                    align: 'center',
                    dataIndex: 'mainPrice3',
                    width: 150
                  },
                  {
                    title: '安装价',
                    align: 'center',
                    dataIndex: 'installPrice3',
                    width: 150
                  },
                  {
                    title: '综合单价',
                    align: 'center',
                    dataIndex: 'syntheticalPrice3',
                    width: 150
                  }
                ]
              }
            ]
          },
          {
            title: '预估总产值',
            align: 'center',
            dataIndex: '',
            width: 150,
            children: [
              {
                title: '有合同价（合价）',
                align: 'center',
                dataIndex: '',
                width: 150,
                children: [
                  {
                    title: '主材价',
                    align: 'center',
                    dataIndex: 'mainsumPrice1',
                    width: 150
                  },
                  {
                    title: '安装价',
                    align: 'center',
                    dataIndex: 'installsumPrice1',
                    width: 150
                  },
                  {
                    title: '综合单价',
                    align: 'center',
                    dataIndex: 'contractsumSyntheticalPrice1',
                    width: 150
                  }
                ]
              },
              {
                title: '拟合同价（合价）',
                align: 'center',
                dataIndex: '',
                width: 150,
                children: [
                  {
                    title: '主材价',
                    align: 'center',
                    dataIndex: 'mainsumPrice2',
                    width: 150
                  },
                  {
                    title: '安装价',
                    align: 'center',
                    dataIndex: 'installsumPrice2',
                    width: 150
                  },
                  {
                    title: '综合单价',
                    align: 'center',
                    dataIndex: 'contractsumSyntheticalPrice2',
                    width: 150
                  }
                ]
              },
              {
                title: '合同价（合价）',
                align: 'center',
                dataIndex: '',
                width: 150,
                children: [
                  {
                    title: '主材价',
                    align: 'center',
                    dataIndex: 'mainsumPrice3',
                    width: 150
                  },
                  {
                    title: '安装价',
                    align: 'center',
                    dataIndex: 'installsumPrice3',
                    width: 150
                  },
                  {
                    title: '综合单价',
                    align: 'center',
                    dataIndex: 'contractsumSyntheticalPrice3',
                    width: 150
                  }
                ]
              }
            ]
          },
          {
            title: '本月实现产值（未税）',
            align: 'center',
            dataIndex: '',
            width: 150,
            children: [
              {
                title: '合同价（合价）',
                align: 'center',
                dataIndex: '',
                width: 150,
                children: [
                  {
                    title: '主材价',
                    align: 'center',
                    dataIndex: 'currentMonthmainPrice',
                    width: 150
                  },
                  {
                    title: '安装价',
                    align: 'center',
                    dataIndex: 'currentMonthinstallPrice',
                    width: 150
                  },
                  {
                    title: '合计',
                    align: 'center',
                    dataIndex: 'currentMonthsumPrice',
                    width: 150
                  }
                ]
              }
            ]
          },
          {
            title: '截止上月实现产值（未税）',
            align: 'center',
            dataIndex: '',
            width: 150,
            children: [
              {
                title: '合同价（合价）',
                align: 'center',
                dataIndex: '',
                width: 150,
                children: [
                  {
                    title: '主材价',
                    align: 'center',
                    dataIndex: 'lastMonthmainPrice',
                    width: 150
                  },
                  {
                    title: '安装价',
                    align: 'center',
                    dataIndex: 'lastMonthinstallPrice',
                    width: 150
                  },
                  {
                    title: '合计',
                    align: 'center',
                    dataIndex: 'lastMonthsumPrice',
                    width: 150
                  }
                ]
              }
            ]
          },
          {
            title: '累计实现产值（未税）',
            align: 'center',
            dataIndex: '',
            width: 150,
            children: [
              {
                title: '合同价（合价）',
                align: 'center',
                dataIndex: '',
                width: 150,
                children: [
                  {
                    title: '主材价',
                    align: 'center',
                    dataIndex: 'totalMonthmainPrice',
                    width: 150
                  },
                  {
                    title: '安装价',
                    align: 'center',
                    dataIndex: 'totalMonthinstallPrice',
                    width: 150
                  },
                  {
                    title: '合计',
                    align: 'center',
                    dataIndex: 'totalsumPrice',
                    width: 150
                  }
                ]
              }
            ]
          },
          {
            title: '品牌',
            align: 'center',
            dataIndex: 'brandName',
            width: 150
          },
          {
            title: '备注',
            align: 'center',
            dataIndex: 'remark',
            width: 150
          }
        ]
      }
    },
    created() {
      this.initparms()
    },
    methods: {
      initparms () {
        this.projectId = this.$route.query.projectId
        this.versionId = this.$route.query.versionId
        this.column = this.$route.query.columns
        let columnsStr= this.$route.query.columns
        // 循环columns 控制显示与隐藏
        let params = {
          projectId: this.projectId,
          versionId: this.versionId
        }
        this.queryParam.projectId = this.$route.query.projectId
        if (columnsStr) {
          let newColumns = []
          let queryColumns = columnsStr.split(',')
          this.columns.forEach(column => {
            let dataIndex = column.dataIndex

            queryColumns.forEach(queryColumn => {
              if (dataIndex == queryColumn) {
                newColumns.push(column)
              }
            })
          })
          this.newColumns = newColumns
        } else {
          this.newColumns = this.columns
        }
      }
    }
  }
</script>
<style scoped>

 </style>